import Koa from 'koa'
import fs from 'fs'


const appRouter = (app: Koa) => {
    fs.readdirSync(__dirname).forEach((file) => {
        if (file === 'index.ts' || file === 'index.js') {
            return
        } else {
            const route = require(`./${file}`).default
            app.use(route.routes()).use(route.allowedMethods()) //allowedMethods 允许使用options方法
        }
    })
}

export default appRouter
